package com.xyazm.order.remote;

import com.xyazm.common.core.JsonResult;
import com.xyazm.common.utils.CheckResultUtil;
import com.xyazm.inventory.api.IInventoryApi;
import com.xyazm.inventory.domain.param.DeductProductParam;
import com.xyazm.inventory.domain.param.ReleaseProductStockParam;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

/**
 * 库存服务远程调用接口
 * @author xuyou
 * @date 2022年08月28日 21:34
 */
@Component
public class InventoryRemote {

    /**
     * 库存服务
     */
    @DubboReference(version = "1.0.0")
    private IInventoryApi inventoryApi;


    public void deductProductStock(DeductProductParam lockProductParam) {
        JsonResult<Void> jsonResult = inventoryApi.deductProductStock(lockProductParam);
        CheckResultUtil.checkResult(jsonResult,"锁定商品库存");
    }


    public void releaseProductStock(ReleaseProductStockParam releaseProductStockParam) {
        JsonResult<Void> jsonResult = inventoryApi.releaseProductStock(releaseProductStockParam);
        CheckResultUtil.checkResult(jsonResult,"释放商品库存");
    }
}
